package com.zg.common.core.dao.autoform.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zg.common.core.dao.autoform.DiyForm;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * @author Zxb
 */
@Mapper
public interface DiyFormMapper extends BaseMapper<DiyForm> {

    @Select("<script>"+
            "SELECT t.table_name,comments FROM user_tables t " +
            " left join user_tab_comments c on c.table_name=t.table_name" +
            " <where> "+
            "  <if test=\"tableName != null and tableName != ''\"> t.table_name like '%' || #{tableName} || '%'  or c.comments like '%' || #{tableName} || '%' </if>" +
            " </where> "+
            " ORDER BY t.table_name"+
            "</script>")

    Page<Map<String, Object>> pageTable(@Param("page") Page<Map<String,Object>> page, @Param("tableName") String tableName);


    @Select("SELECT  comments   " +
            "FROM  user_tab_comments " +
            "where  table_name=#{tableName}")
     String getComments(String tableName);
}
